package com.pptv.ads.client;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JobInvocationHandler implements InvocationHandler{
	
	private Object target;
	Logger Log = LoggerFactory.getLogger(JobInvocationHandler.class);
	
	public JobInvocationHandler(Object target) {
		super();
		this.target = target;
	}
	
	public void before(){
		Log.info("before...");
	}
	
	public void after(){
		Log.info( "after....." );
	}
	
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		if("execute".equals(method.getName())){
			before();
			Object res = method.invoke(target, args);
			after();
			return res;
		}else{
			Object res = method.invoke(target, args);
			return res;
		}
	}

}
